package com.example.shixunandjavagotoyangchen.BoosYang.Day001.Day00105;

import com.example.modelviewpresenter.Model.BasterModel;

import java.util.List;

import io.reactivex.Observer;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;

/**
 * 作者:二徒
 * 时间：2021/10/28- 11:45
 * 功能实现：
 */
public class ClassroomDay00105Model extends BasterModel implements ClassroomDay00105Contion.moder {
    @Override
    public void getmoder(String name, ClassroomDay00105Callback callbck) {
        ClassroomDay00105Okhttp.getOkhttp().getRetrofit().create(ClassroomDay00105Api.class).getclassroom(name)
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeOn(Schedulers.computation())
                .subscribe(new Observer<ClassroomDay00105Bean>() {
                    @Override
                    public void onSubscribe(Disposable d) {

                    }

                    @Override
                    public void onNext(ClassroomDay00105Bean classroomDay00105Bean) {
                        List<ClassroomDay00105Bean.DataBean> dataBeans = classroomDay00105Bean.getData();
                        callbck.suees(dataBeans);
                    }

                    @Override
                    public void onError(Throwable e) {
                        callbck.filai("失败了"+e.getMessage().toString());
                    }

                    @Override
                    public void onComplete() {

                    }
                });
    }
}
